package com.xg.xmall.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xg.comm.pojo.DataGridResult;
import com.xg.comm.pojo.XmallResult;
import com.xg.xmall.pojo.TbItem;
import com.xg.xmall.service.ItemService;

@Controller
public class ItemController {
	@Autowired
	private ItemService itemService;

	@RequestMapping("/item/{itemId}")
	@ResponseBody
	public TbItem getItemById(@PathVariable long itemId) {

		TbItem item = itemService.getItemById(itemId);
		return item;
	}

	@RequestMapping("/item/list")
	@ResponseBody
	public DataGridResult getItemList(Integer page, Integer rows) {

		DataGridResult list = itemService.getItemList(page, rows);
		return list;
	}
	
	@RequestMapping(value="/item/save",method =RequestMethod.POST)
	@ResponseBody
	public XmallResult addItem(TbItem item, String desc) {
		//TbItemDesc itemDesc = new TbItemDesc();
		//itemDesc.setItemDesc(desc);
		XmallResult result = itemService.createItem(item);
		return result;
	}


}
